package com.example.mybaseapp.widget

import android.content.Context
import android.graphics.Canvas
import android.util.AttributeSet
import android.util.Log
import android.view.View

class MyView: View {
    private val TAG = javaClass.simpleName
    constructor(context: Context) : super(context) {
        // 构造函数处理
        initView()
    }

    constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
        // 构造函数处理，处理从 XML 布局文件中传入的属性
        initAttars(attrs)
        initView()
    }

    constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
        // 构造函数处理，处理从 XML 布局文件中传入的属性和样式
        initAttars(attrs)
        initView()
    }

    private fun initAttars(attrs: AttributeSet) {

    }

    private fun initView() {
    }

    override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) {
        super.onLayout(changed, left, top, right, bottom)
        Log.d(TAG, "onLayout: ")
    }

    override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec)
        Log.d(TAG, "onMeasure: ")

    }

    override fun onDraw(canvas: Canvas) {
        super.onDraw(canvas)
        Log.d(TAG, "onDraw: ")
    }
}